﻿using System;
using System.Globalization;
using System.Net.Http;
using CkSoftware.GroupMe.Sdk.Core;
using CkSoftware.GroupMe.Sdk.Core.Dao;
using CkSoftware.GroupMe.Sdk.Groups.Dao;

namespace CkSoftware.GroupMe.Sdk.Groups.Commands
{
	/// <summary>
	/// Group add member results command (GroupMe documentation: <see href="https://dev.groupme.com/docs/v3#members_results" />).
	/// </summary>
	public class GroupAddMemberResultsCommand : IWebApiCommand<GroupMeApiResponse<GroupAddMemberResultsData>>
	{
		private const string CommandNameFormat = "/groups/{0}/members/results/{1}";

		private readonly string _groupId;
		private readonly Guid _resultsId;

		/// <summary>
		/// Instantiates a new <see cref="GroupAddMemberResultsCommand" /> for the given group-id and results id.
		/// </summary>
		/// <param name="groupId">The group id which should be checked for the add-result.</param>
		/// <param name="resultsId">The resultsId returned in the add-command response.</param>
		public GroupAddMemberResultsCommand(string groupId, Guid resultsId)
		{
			_groupId = groupId;
			_resultsId = resultsId;
		}

		/// <summary>
		/// Defines if the command is executed once.
		/// </summary>
		public bool CommandExecuted { get; set; }

		/// <summary>
		/// The name of the command to be executed.
		/// </summary>
		public string CommandName
		{
			get { return string.Format(CultureInfo.CurrentCulture, CommandNameFormat, _groupId, _resultsId); }
		}

		/// <summary>
		/// The http method to execute this command.
		/// </summary>
		public HttpMethod HttpMethod
		{
			get { return HttpMethod.Get; }
		}

		/// <summary>
		/// The parameters which should be used on command execution.
		/// </summary>
		public IWebApiCommandParameters Parameters
		{
			get { return null; }
		}
	}
}